package com.study.bigdata.spark.core.rdd.operator.transform

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object Scala06_RDD_Operator_Transform_1 {
  def main(args: Array[String]): Unit = {

    val conf = new SparkConf().setMaster("local[*]").setAppName("RDD")
    // 中间会有瞬间的落盘的过程
    conf.set("spark.local.dir","D:\\hadoopbook\\spark\\test")
    val sc = new SparkContext(conf)

    // TODO 算子 - 转换 - groupBy
    val rdd = sc.makeRDD(
      List("Hello", "hive", "hbase", "Hadoop")
    )
    //将List("Hello", "hive", "hbase", "Hadoop")根据单词首写字母进行分组
    val rdd1 = rdd.groupBy(_.substring(0,1)/*.toUpperCase()*/)
    rdd1.collect().foreach(println)
    /*
    (h,CompactBuffer(hive, hbase))
    (H,CompactBuffer(Hello, Hadoop))
     */
    sc.stop()

  }

}
